package com.yfp.goods.api.factory;

import com.yfp.goods.api.RemoteGoodsService;
import com.yfp.common.core.domain.R;
import com.yfp.goods.domain.ComboDetailImg;
import com.yfp.goods.domain.Goods;
import com.yfp.goods.domain.GoodsNutritive;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteGoodsFallbackFactory implements FallbackFactory<RemoteGoodsService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteGoodsFallbackFactory.class);

    @Override
    public RemoteGoodsService create(Throwable throwable) {
        log.error("goods服务调用失败:{}", throwable.getMessage());
        return new RemoteGoodsService() {

            @Override
            public R<List<ComboDetailImg>> queryComboDetailImg(String comboId) {
                return R.fail();
            }

            @Override
            public R<List<GoodsNutritive>> queryGoodsNutritiveByGoodsId(String goodsId) {
                return R.fail();
            }

            @Override
            public R<String> getResourceUrl(Integer resourceType, String resourceId) {
                return R.fail();
            }

            @Override
            public R<List<Goods>> queryByComboId(String comboId) {
                 return R.fail();
            }
        };
    }
}